<template>
	<view>
		<image class="examImage" :src="imageSrc" mode="aspectFit"></image>
		<view v-if="examType=='exam'" class="">
			<view class="finishText">
				恭喜您完成考试！考试结果将在之后公布。请在“考试成绩”处查询。
			</view>
			<!-- <view class="btnArea">
				<u-button v-if="examType=='exam'" class="btnClass" type="success" :ripple="true" shape="circle"
					@click="showError">考试结果</u-button>
				<u-button class="btnClass" type="primary" :ripple="true" shape="circle" @click="backToHome">返回首页
				</u-button>
			</view> -->
		</view>
		<view v-if="examType=='paper'|| examType=='know' || examType=='course' " class="">
			<view class="finishText">
				<view>考试名称：<text>{{paperName}}</text></view>
				<!-- 练习类型{{paperRecord.paperName}} -->
				<view>总题数：<text>{{paperRecord.totalQueNum}}</text>题 </view>
				<view>答对：<text>{{paperRecord.rightQueNum}}</text>题</view>
				<view>得分：<text>{{paperRecord.score}}</text> 分 </view>
			</view>
		</view>
		<view class="btnArea">
			<u-button class="btnClass" type="primary" :ripple="true" shape="circle" @click="backToHome">返回首页
			</u-button>
		</view>

	</view>
</template>

<script>
	export default {
		props: {},
		data() {
			return {
				imageSrc: 'https://s3.ax1x.com/2021/02/09/yavsUS.png',
				recordId: '',
				examType: '',
				paperRecord: {},
				time: '',
				showExamResultBtn: false
			}
		},
		methods: {
			backToHome() {
				uni.switchTab({
					url: '/pages/exam/exam',
				})
			},
			showError() {
				console.log("本次考试的recordId：", this.recordId);
				this.$u.route('/pages/exam/examReviewPage', {
					recordId: this.recordId
				})
			}
		},
		computed: {
			paperName() {
				if (this.paperRecord.paperName) {
					return this.paperRecord.paperName
				} else {
					return "知识点练习"
				}
			}
		},
		onLoad(options) {
			this.recordId = options.recordId
			this.examType = options.examType
			this.time = options.time

			if (options.examType == 'paper' || options.examType == 'know') {
				this.$api.paperResult(options.exerciseId)
					.then(res => {
						console.log('模拟考试交卷结果:', res);
						this.paperRecord = res.values.record
					})
			} else if (options.examType == 'course') {
				this.$api.checkTheory(this.$store.state.access_token, options.exerciseId)
					.then(res => {
						console.log('模拟考试交卷结果:', res);
						this.paperRecord = res.values.result
					})
			}
		}

	}
</script>

<style lang="scss" scoped>
	.examImage {
		width: 100%;
		display: flex;
		justify-content: center;
		// background-color: #000000;
		margin-top: 100rpx;
		height: 300rpx;
	}

	.finishText {
		// margin: 100rpx 200rpx;
		padding: 50rpx;
		letter-spacing: 0.2em;
		font-size: 32rpx;
		display: flex;
		flex-direction: column;
		align-items: center;

		text {
			color: $theme-color;
			font-weight: bold;
		}
	}

	.btnArea {
		display: flex;
		margin-top: 50rpx;

		.btnClass {
			width: 300rpx;
		}
	}

	.infoArea {
		display: flex;
		flex-direction: column;
		justify-content: center;
	}
</style>
